From e97f706d7b164b34b3eab118e33462e3c0f0451b Mon Sep 17 00:00:00 2001 From: robertl Date: Sun, 6 Apr 2008 03:41:10 +0000 Subject: [PATCH] Garmin, GDB: Add 'bitscategory' options to allow specifying > 1 category at a time. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@3170 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/garmin.c | 13 +++++++++++++ gpsbabel/gdb.c | 14 ++++++++++++-- .../formats/options/garmin-bitscategory.xml | 19 +++++++++++++++++++ .../formats/options/gdb-bitscategory.xml | 19 +++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 gpsbabel/xmldoc/formats/options/garmin-bitscategory.xml create mode 100644 gpsbabel/xmldoc/formats/options/gdb-bitscategory.xml diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 81a95675b..7ee0126cf 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -43,6 +43,8 @@ static char *snlen = NULL; static char *snwhiteopt = NULL; static char *deficon = NULL; static char *category = NULL; +static char *categorybitsopt = NULL; +static int categorybits; #define MILITANT_VALID_WAYPT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" @@ -64,6 +66,8 @@ arglist_t garmin_args[] = { NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, { "category", &category, "Category number to use for written waypoints", NULL, ARGTYPE_INT, "1", "16"}, + { "bitscategory", &categorybitsopt, "Bitmap of categories", + NULL, ARGTYPE_INT, "1", "65535"}, ARG_TERMINATOR }; @@ -104,6 +108,10 @@ rw_init(const char *fname) return; } + if (categorybitsopt) { + categorybits = strtol(categorybitsopt, NULL, 0); + } + if (GPS_Init(fname) < 0) { fatal(MYNAME ":Can't init %s\n", fname); } @@ -232,6 +240,8 @@ rw_init(const char *fname) if (receiver_charset) cet_convert_init(receiver_charset, 1); + + } static void @@ -809,6 +819,9 @@ xasprintf(&src, "%s %s", &wpt->shortname[2], src); if (category) { way[i]->category = 1 << (atoi(category) - 1); } + if (categorybits) { + way[i]->category = categorybits; + } #if SOON garmin_fs_garmin_before_write(wpt, way[i], gps_waypt_type); #endif diff --git a/gpsbabel/gdb.c b/gpsbabel/gdb.c index 71127d044..51a0cf359 100644 --- a/gpsbabel/gdb.c +++ b/gpsbabel/gdb.c @@ -107,8 +107,8 @@ /*******************************************************************************/ -/* static char gdb_release[] = "$Revision: 1.61 $"; */ -static char gdb_release_date[] = "$Date: 2008-01-09 23:06:04 $"; +/* static char gdb_release[] = "$Revision: 1.62 $"; */ +static char gdb_release_date[] = "$Date: 2008-04-06 03:41:10 $"; static gbfile *fin, *fout; static int gdb_ver, gdb_category, gdb_via, gdb_roadbook; @@ -120,6 +120,7 @@ static char *gdb_opt_category; static char *gdb_opt_ver; static char *gdb_opt_via; static char *gdb_opt_roadbook; +static char *gdb_opt_bitcategory; static int waypt_flag; static int route_flag; @@ -1635,6 +1636,11 @@ init_writer(const char *fname) MYNAME ": cat must be between 1 and 16!"); gdb_category = 1 << (gdb_category - 1); } + + if (gdb_opt_bitcategory) { + gdb_category = strtol(gdb_opt_bitcategory, NULL, 0); + } + if (gdb_ver >= GDB_VER_UTF8) cet_convert_init(CET_CHARSET_UTF8, 1); @@ -1686,12 +1692,15 @@ write_data(void) #define GDB_OPT_VER "ver" #define GDB_OPT_VIA "via" #define GDB_OPT_CATEGORY "cat" +#define GDB_OPT_BITCATEGORY "bitcategory" #define GDB_OPT_ROADBOOK "roadbook" static arglist_t gdb_args[] = { {GDB_OPT_CATEGORY, &gdb_opt_category, "Default category on output (1..16)", NULL, ARGTYPE_INT, "1", "16"}, + {GDB_OPT_BITCATEGORY, &gdb_opt_bitcategory, "Bitmap of categories", + NULL, ARGTYPE_INT, "1", "65535"}, {GDB_OPT_VER, &gdb_opt_ver, "Version of gdb file to generate (1..3)", "2", ARGTYPE_INT, "1", "3"}, @@ -1701,6 +1710,7 @@ static arglist_t gdb_args[] = { {GDB_OPT_ROADBOOK, &gdb_opt_roadbook, "Include major turn points (with description) from calculated route", NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, + ARG_TERMINATOR }; diff --git a/gpsbabel/xmldoc/formats/options/garmin-bitscategory.xml b/gpsbabel/xmldoc/formats/options/garmin-bitscategory.xml new file mode 100644 index 000000000..5b2c8d668 --- /dev/null +++ b/gpsbabel/xmldoc/formats/options/garmin-bitscategory.xml @@ -0,0 +1,19 @@ + + This option is closely related to the 'category' option. While category + allows you to choose a single category that waypoints should appear in, + this options allows you to specify a bitmask to be used for the category. + Options may be specified in either decimal or hex. + + + Example for garmin bitcategory option to put all waypoints in categories 1 and 16. + + The following two commands are equivalent. They place a the point in both the first and last of the sixteen available categories. + + gpsbabel -i gpx -f PocketQuery.gpx -o garmin,bitcategory=32769 -F usb: + + + gpsbabel -i gpx -f PocketQuery.gpx -o garmin,bitcategory=0x8001 -F usb: + + + + diff --git a/gpsbabel/xmldoc/formats/options/gdb-bitscategory.xml b/gpsbabel/xmldoc/formats/options/gdb-bitscategory.xml new file mode 100644 index 000000000..18bf952ca --- /dev/null +++ b/gpsbabel/xmldoc/formats/options/gdb-bitscategory.xml @@ -0,0 +1,19 @@ + + This option is closely related to the 'category' option. While category + allows you to choose a single category that waypoints should appear in, + this options allows you to specify a bitmask to be used for the category. + Options may be specified in either decimal or hex. + + + Example for gdb bitcategory option to put all waypoints in categories 1 and 16. + + The following two commands are equivalent. They place a the point in both the first and last of the sixteen available categories. + + gpsbabel -i gpx -f PocketQuery.gpx -o gdb,bitcategory=32769 -F foo.gdb + + + gpsbabel -i gpx -f PocketQuery.gpx -o gdb,bitcategory=0x8001 -F foo.gdb + + + + -- 2.30.2